package cn.five.stream.surfaceEncoder.filter;

import java.nio.FloatBuffer;

import android.content.Context;
import android.opengl.GLES20;
import cn.five.stream.surfaceEncoder.gles.GlUtil;

import com.jemi.androidh264streamdemo.R;

/**
 * Created by foxy on 2016/8/17.
 */
public class CameraFilterBeauty extends CameraFilter{
    private int singleStepOffset;

    private static final float offset_array[] = {
            2, 2,
    };

    public CameraFilterBeauty(Context context) {
        super(context);
        offset_array[0] = offset_array[0] / 90;
        offset_array[1] = offset_array[1] / 160;
    }

    @Override protected int createProgram(Context applicationContext) {
        return GlUtil.createProgram(applicationContext, R.raw.vertex_shader,
                R.raw.fragment_shader_beauty);
    }

    @Override protected void getGLSLValues() {
        super.getGLSLValues();

        singleStepOffset = GLES20.glGetUniformLocation(mProgramHandle, "singleStepOffset");
    }

    @Override
    protected void bindGLSLValues(float[] mvpMatrix, FloatBuffer vertexBuffer, int coordsPerVertex,
                                  int vertexStride, float[] texMatrix,FloatBuffer texBuffer, int texStride) {
        super.bindGLSLValues(mvpMatrix, vertexBuffer, coordsPerVertex, vertexStride,texMatrix,
                texBuffer, texStride);

        GLES20.glUniform2fv(singleStepOffset, 1, offset_array, 0);
    }

	@Override
	protected void unbindTexture() {
		super.unbindTexture();
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
	}
    
    
    
    
}
